/*
 * @(#)QueryMethodConfig.java
 * Date 2013-08-13
 * Version 1.0
 * Author Jim Horner
 * Copyright (c)2012
 */


package us.hornerscorners.lamppost.registry.config;

import java.util.ArrayList;
import java.util.List;

import us.hornerscorners.lamppost.registry.constant.IQueryName;
import us.hornerscorners.lamppost.registry.constant.QueryReturnModelType;
import us.hornerscorners.lamppost.registry.constant.QuerySlotName;


/**
 *
 * @author jim
 */
public class QueryMethodConfig {

    /** Field description */
    private boolean checkPatientId;

    /** Field description */
    private List<QueryParameterConfig> parameters;

    /** Field description */
    private IQueryName queryName;

    /** Field description */
    private final List<QueryReturnModelType> returnTypes;

    /**
     * Constructs ...
     *
     */
    public QueryMethodConfig() {

        super();
        this.returnTypes = new ArrayList<>();
        this.parameters = new ArrayList<>();
    }

    /**
     * Method description
     *
     *
     *
     * @return
     */
    public QueryParameterConfig findParameterConfig(QuerySlotName slotName) {

        QueryParameterConfig result = null;

        for (QueryParameterConfig config : this.parameters) {

            if (config.getSlotName().equals(slotName)) {

                result = config;

                break;
            }
        }

        return result;
    }

    /**
     * Method description
     *
     *
     * @return
     */
    public String getId() {
        return this.queryName.getUUID();
    }

    /**
     * Method description
     *
     *
     * @return
     */
    public List<QueryParameterConfig> getParameters() {
        return parameters;
    }

    /**
     * Method description
     *
     *
     * @return
     */
    public IQueryName getQueryName() {
        return queryName;
    }

    /**
     * Method description
     *
     *
     * @return
     */
    public List<QueryReturnModelType> getReturnTypes() {
        return returnTypes;
    }

    /**
     * Method description
     *
     *
     * @return
     */
    public boolean isCheckPatientId() {
        return checkPatientId;
    }

    /**
     * Method description
     *
     *
     * @param checkPatientId
     */
    public void setCheckPatientId(boolean checkPatientId) {
        this.checkPatientId = checkPatientId;
    }

    /**
     * Method description
     *
     *
     * @param queryParameters
     */
    public void setParameters(List<QueryParameterConfig> queryParameters) {

        this.parameters.clear();
        this.parameters.addAll(queryParameters);
    }

    /**
     * Method description
     *
     *
     * @param queryName
     */
    public void setQueryName(IQueryName queryName) {
        this.queryName = queryName;
    }

    /**
     * Method description
     *
     *
     * @param returnTypes
     */
    public void setReturnTypes(List<QueryReturnModelType> returnTypes) {

        this.returnTypes.clear();
        this.returnTypes.addAll(returnTypes);
    }
}
